//#include "stdafx.h"
#include "simpleDll.h"
#include "..\common\suServiceInterface.h"
#include <iostream>
using namespace std;

void    SimpleDll::initialize()
{
	string wsdl = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
		"<definitions xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:s=\"http://www.w3.org/2001/XMLSchema\" xmlns:s0=\"http://tempuri.org/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:tm=\"http://microsoft.com/wsdl/mime/textMatching/\" xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\" targetNamespace=\"http://tempuri.org/\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\">"
		"<types>"
		"<s:schema elementFormDefault=\"qualified\" targetNamespace=\"http://tempuri.org/\">"
		"<s:element name=\"run\">"
		"<s:complexType>"
		"<s:sequence>"
		"<s:element minOccurs=\"0\" maxOccurs=\"1\" name=\"cmd\" type=\"s:string\" />"
		"</s:sequence>"
		"</s:complexType>"
		"</s:element>"
		"<s:element name=\"runResponse\">"
		"<s:complexType>"
		"<s:sequence>"
		"<s:element minOccurs=\"0\" maxOccurs=\"1\" name=\"runResult\" type=\"s:string\" />"
		"</s:sequence>"
		"</s:complexType>"
		"</s:element>"
		"</s:schema>"
		"</types>"
		"<message name=\"runSoapIn\">"
		"<part name=\"parameters\" element=\"s0:run\" />"
		"</message>"
		"<message name=\"runSoapOut\">"
		"<part name=\"parameters\" element=\"s0:runResponse\" />"
		"</message>"
		"<portType name=\"webserivceClassSoap\">"
		"<operation name=\"run\">"
		"<input message=\"s0:runSoapIn\" />"
		"<output message=\"s0:runSoapOut\" />"
		"</operation>"
		"</portType>"
		"<binding name=\"webserivceClassSoap\" type=\"s0:webserivceClassSoap\">"
		"<soap:binding transport=\"http://schemas.xmlsoap.org/soap/http\" style=\"document\" />"
		"<operation name=\"run\">"
		"<soap:operation soapAction=\"http://tempuri.org/run\" style=\"document\" />"
		"<input>"
		"<soap:body use=\"literal\" />"
		"</input>"
		"<output>"
		"<soap:body use=\"literal\" />"
		"</output>"
		"</operation>"
		"</binding>"
		"<service name=\"webserivceClass\">"
		"<port name=\"webserivceClassSoap\" binding=\"s0:webserivceClassSoap\">"
		"<soap:address location=\"http://localhost:5001/regrule\" />"
		"</port>"
		"</service>"
		"</definitions>";
	setWsdl(wsdl);
}
string  SimpleDll::info()            {return "Test Dll";}
string  SimpleDll::wsdl()            {return getWsdl();}
string  SimpleDll::run(string cmd)
{
	setlocale(LC_ALL, ".936");
	std::cout << cmd;
	return cmd;
}
//cmd must be something like 
//ecaex("name","pri","everymin","event(pa,pb)","condition","action(pa,pb)","owner")
string  SimpleDll::run(string name, string cmd)
{	
	std::cout << name << " is running " << cmd << std::endl;
	suStatus *p = (suStatus*)(getStatus());
	//p->setGlobalVar("TEST",cmd);
	return getStatus()->reg_one_rule(cmd);

	return cmd;
}
